package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.Menu;
import com.itheima.pojo.Permission;
import com.itheima.pojo.Role;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * Created by QIUzh on 2020/11/21 17:33
 */

public interface SettingDao {
    Page<Role> selectByCondition(String queryString);

    void add(Role role);

    int queryByname(@Param("name") String name,@Param("keyword") String keyword);

    void delete(Integer id);

    void edit(Role role);

    Role findById(Integer id);

    List<Integer> findPermissionById(Integer id);

    @Select("select * from t_permission")
    List<Permission> findPermissionAll();

    List<Integer> findPrIdsByid(Integer id);
    @Select("select * from t_menu")
    List<Menu> findMenuAll();

    List<Integer> findMnIdsByid(Integer id);

    void setRoleAndPermission( @Param("id") Integer id,@Param("checkId") Integer checkId);

    void setRoleAndMenu( @Param("id") Integer id,@Param("checkId2") Integer checkId2);

    @Delete("delete from t_role_permission where role_id=#{id}")
    void deleteRoleAndPermission(Integer id);

    @Delete("delete from t_role_menu where role_id=#{id}")
    void deleteRoleAndMenu(Integer id);

    @Select("SELECT count(*) FROM t_user_role where role_id = #{id}")
    int findUserByid(Integer id);
    @Select("SELECT count(*) FROM t_role_menu where role_id = #{id}")
    int findMenuByid(Integer id);
    @Select("SELECT count(*) FROM t_role_permission where role_id = #{id}")
    int findPermissionByid(Integer id);
}
